#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	unordered_map<string, string> a;
	string str;
	while(getline(cin, str)){
		if(!('a' <= str[0] && str[0] <= 'z'))
			break;
		
		int idx = str.find(' ');
		if(idx == -1){
			break;
		}
		idx++;
		string x(str, idx);
		string y(str, 0, idx);
		a[x] = y;
	}
	while(cin>>str){
		if(a.count(str))
			cout<<a[str]<<endl;
		else
			cout<<"eh"<<endl;
	};
	return 0;
}
